package bsi.vn.FirstApp;

import bsi.vn.Lib.ProcessFunc;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TabHost.TabSpec;

@SuppressWarnings("deprecation")
public class AtmContainActivity extends TabActivity{
	private TabHost tabHost;
	private TabWidget tabWidget;
	private Context context = AtmContainActivity.this;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tab);
		
		Bundle extras = getIntent().getExtras();
		if (extras == null) {
			return;
		}
		int loc_iATMId = extras.getInt("ATMId");
		
		tabHost = getTabHost();
		tabWidget = tabHost.getTabWidget();
		
		TabSpec tabSpec1 = tabHost.newTabSpec("general");
		tabSpec1.setIndicator("General");
		Intent intent1 = new Intent(context, ATMDetailActivity.class);
		intent1.putExtra("ATMId", loc_iATMId);
		tabSpec1.setContent(intent1);
		
		TabSpec tabSpec2 = tabHost.newTabSpec("ticket");
		tabSpec2.setIndicator("Ticket");
		Intent intent2 = new Intent(context, ATMTicketListActivity.class);
		intent2.putExtra("ATMId", loc_iATMId);
		tabSpec2.setContent(intent2);
		
		TabSpec tabSpec3 = tabHost.newTabSpec("contract");
		tabSpec3.setIndicator("Contract");
		Intent intent3 = new Intent(context, ContractListActivity.class);
		intent3.putExtra("ATMId", loc_iATMId);
		tabSpec3.setContent(intent3);
		

		
		tabHost.addTab(tabSpec1);
		tabHost.addTab(tabSpec2);
		tabHost.addTab(tabSpec3);
		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		 MenuInflater menuInflater = getMenuInflater();
	        menuInflater.inflate(R.menu.atmsearch, menu);
		return super.onCreateOptionsMenu(menu);
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if(item.getItemId() != R.id.menu_sub && item.getItemId() != R.id.menu_ATM){
			startActivity(ProcessFunc.MenuAction(this, item));
		}
		return true;
	}
}
